package com.ccq.controller;

import com.alibaba.fastjson.JSON;
import com.ccq.model.*;
import com.ccq.service.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = { "last" })
public class LastAllController {
    @Autowired
    LastAllService lastAllService;

    @Autowired
    LastRentingService lastRentingService;

    @Autowired
    LastRecordServicce lastRecordServicce;

    @Autowired
    LastUserService lastUserService;

    @Autowired
    LastKnowledgeService lastKnowledgeService;

    @Autowired
    LastAllfloorService lastAllfloorService;
    //二手房
    @ApiOperation(value="后台二手列表", notes="后台二手列表")
    @RequestMapping(value = "secondlist",method = RequestMethod.POST)
    @ResponseBody
    public String secondlist(String page){
        if(page==null)page="1";
        int pages=Integer.parseInt(page);
        String ls=lastAllService.secondlist(pages);
        return ls;
    }

    @ApiOperation(value="后台二手添加", notes="后台二手添加")
    @RequestMapping(value = "add",method = RequestMethod.POST)
    @ResponseBody
    public int add(Second second){
        int add=lastAllService.add(second);
        return add;
    }

    @ApiOperation(value="后台二手修改1", notes="后台二手修改1")
    @RequestMapping(value = "edit1",method = RequestMethod.POST)
    @ResponseBody
    public String edits(int id){
        String se=lastAllService.eidts(id);
        return se;
    }

    @ApiOperation(value="后台二手修改", notes="后台二手修改")
    @RequestMapping(value = "edit",method = RequestMethod.POST)
    @ResponseBody
    public String edit(Second second){
        String ls=lastAllService.edit(second);
        return ls;
    }

    @ApiOperation(value="后台二手删除", notes="后台二手删除")
    @RequestMapping(value = "del",method = RequestMethod.POST)
    @ResponseBody
    public String del(int id){
        String ls=lastAllService.del(id);
        return ls;
    }

    //租房
    @ApiOperation(value="后台租房列表", notes="后台租房列表")
    @RequestMapping(value = "rentlist",method = RequestMethod.POST)
    @ResponseBody
    public String rentlist(String page){
        if(page==null)page="1";
        int pages=Integer.parseInt(page);
        String ls=lastRentingService.rentlist(pages);
        return ls;
    }

    @ApiOperation(value="后台租房添加", notes="后台租房添加")
    @RequestMapping(value = "rentadd",method = RequestMethod.POST)
    @ResponseBody
    public String rentadd(Renting renting){
        String aListJson = JSON.toJSONString(renting);
        System.out.println(aListJson);
        String add=lastRentingService.add(renting);
        return add;
    }

    @ApiOperation(value="后台租房修改1", notes="后台租房修改1")
    @RequestMapping(value = "rentedit1",method = RequestMethod.POST)
    @ResponseBody
    public String rentedits(int id){
        String se=lastRentingService.eidts(id);
        return se;
    }

    @ApiOperation(value="后台租房修改", notes="后台租房修改")
    @RequestMapping(value = "rentedit",method = RequestMethod.POST)
    @ResponseBody
    public String rentedit(Renting renting){
        String ls=lastRentingService.edit(renting);
        return ls;
    }

    @ApiOperation(value="后台租房删除", notes="后台租房删除")
    @RequestMapping(value = "rentdel",method = RequestMethod.POST)
    @ResponseBody
    public String rentdel(int id){
        String ls=lastRentingService.del(id);
        return ls;
    }



    //记录
    @ApiOperation(value="后台租房列表", notes="后台租房列表")
    @RequestMapping(value = "recordlist",method = RequestMethod.POST)
    @ResponseBody
    public String recordlist(String page){
        if(page==null)page="1";
        int pages=Integer.parseInt(page);
        String ls=lastRecordServicce.rentlist(pages);
        return ls;
    }

    @ApiOperation(value="后台租房添加", notes="后台租房添加")
    @RequestMapping(value = "recordadd",method = RequestMethod.POST)
    @ResponseBody
    public String recordadd(Record record){
        String aListJson = JSON.toJSONString(record);
        System.out.println(aListJson);
        String add=lastRecordServicce.add(record);
        return add;
    }

    @ApiOperation(value="后台租房修改1", notes="后台租房修改1")
    @RequestMapping(value = "recordedit1",method = RequestMethod.POST)
    @ResponseBody
    public String recordedits(int id){
        String se=lastRecordServicce.eidts(id);
        return se;
    }

    @ApiOperation(value="后台租房修改", notes="后台租房修改")
    @RequestMapping(value = "recordedit",method = RequestMethod.POST)
    @ResponseBody
    public String recordedit(Record renting){
        String ls=lastRecordServicce.edit(renting);
        return ls;
    }

    @ApiOperation(value="后台租房删除", notes="后台租房删除")
    @RequestMapping(value = "recorddel",method = RequestMethod.POST)
    @ResponseBody
    public String recorddel(int id){
        String ls=lastRecordServicce.del(id);
        return ls;
    }

    //用户管理
    @ApiOperation(value="后台租房列表", notes="后台租房列表")
    @RequestMapping(value = "userlist",method = RequestMethod.POST)
    @ResponseBody
    public String userlist(String page){
        if(page==null)page="1";
        int pages=Integer.parseInt(page);
        String ls=lastUserService.userlist(pages);
        return ls;
    }

    @ApiOperation(value="后台租房添加", notes="后台租房添加")
    @RequestMapping(value = "useradd",method = RequestMethod.POST)
    @ResponseBody
    public String useradd(User user){
        String aListJson = JSON.toJSONString(user);
        System.out.println(aListJson);
        String add=lastUserService.add(user);
        return add;
    }

    @ApiOperation(value="后台租房修改1", notes="后台租房修改1")
    @RequestMapping(value = "useredit1",method = RequestMethod.POST)
    @ResponseBody
    public String useredits(int id){
        String se=lastUserService.eidts(id);
        return se;
    }

    @ApiOperation(value="后台租房修改", notes="后台租房修改")
    @RequestMapping(value = "useredit",method = RequestMethod.POST)
    @ResponseBody
    public String useredit(User user){
        String ls=lastUserService.edit(user);
        return ls;
    }

    @ApiOperation(value="后台租房删除", notes="后台租房删除")
    @RequestMapping(value = "userdel",method = RequestMethod.POST)
    @ResponseBody
    public String userdel(int id){
        String ls=lastUserService.del(id);
        return ls;
    }

    //知识库knowledge
    @ApiOperation(value="后台租房列表", notes="后台租房列表")
    @RequestMapping(value = "knowledgelist",method = RequestMethod.POST)
    @ResponseBody
    public String knowledgelist(String page){
        if(page==null)page="1";
        int pages=Integer.parseInt(page);
        String ls=lastKnowledgeService.rentlist(pages);
        return ls;
    }

    @ApiOperation(value="后台租房添加", notes="后台租房添加")
    @RequestMapping(value = "knowledgeadd",method = RequestMethod.POST)
    @ResponseBody
    public String knowledgeadd(Knowledage knowledage){
        String aListJson = JSON.toJSONString(knowledage);
        System.out.println(aListJson);
        String add=lastKnowledgeService.add(knowledage);
        return add;
    }

    @ApiOperation(value="后台租房修改1", notes="后台租房修改1")
    @RequestMapping(value = "knowledgeedit1",method = RequestMethod.POST)
    @ResponseBody
    public String knowledgeedits(int id){
        String se=lastKnowledgeService.eidts(id);
        return se;
    }

    @ApiOperation(value="后台租房修改", notes="后台租房修改")
    @RequestMapping(value = "knowledgeedit",method = RequestMethod.POST)
    @ResponseBody
    public String knowledgeedit(Knowledage knowledage){
        String ls=lastKnowledgeService.edit(knowledage);
        return ls;
    }

    @ApiOperation(value="后台租房删除", notes="后台租房删除")
    @RequestMapping(value = "knowledgedel",method = RequestMethod.POST)
    @ResponseBody
    public String knowledgedel(int id){
        String ls=lastKnowledgeService.del(id);
        return ls;
    }

    //所有楼盘
    @ApiOperation(value="后台租房列表", notes="后台租房列表")
    @RequestMapping(value = "allfloorlist",method = RequestMethod.POST)
    @ResponseBody
    public String allfloorlist(String page){
        if(page==null)page="1";
        int pages=Integer.parseInt(page);
        String ls=lastAllfloorService.userlist(pages);
        return ls;
    }

    @ApiOperation(value="后台租房添加", notes="后台租房添加")
    @RequestMapping(value = "allflooradd",method = RequestMethod.POST)
    @ResponseBody
    public String allflooradd(Allfloor allfloor){
        String aListJson = JSON.toJSONString(allfloor);
        System.out.println(aListJson);
        String add=lastAllfloorService.add(allfloor);
        return add;
    }

    @ApiOperation(value="后台租房修改1", notes="后台租房修改1")
    @RequestMapping(value = "allflooredit1",method = RequestMethod.POST)
    @ResponseBody
    public String allflooredits(int id){
        String se=lastAllfloorService.eidts(id);
        return se;
    }

    @ApiOperation(value="后台租房修改", notes="后台租房修改")
    @RequestMapping(value = "allflooredit",method = RequestMethod.POST)
    @ResponseBody
    public String allflooredit(Allfloor allfloor){
        String ls=lastAllfloorService.edit(allfloor);
        return ls;
    }

    @ApiOperation(value="后台租房删除", notes="后台租房删除")
    @RequestMapping(value = "allfloordel",method = RequestMethod.POST)
    @ResponseBody
    public String allfloordel(int id){
        String ls=lastAllfloorService.del(id);
        return ls;
    }
}
